package com.test.sdk.receive;

import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
/**
 * @author 徒有琴
 */
@SpringBootApplication
public class ReceiveStarter {
    public static void main(String[] args) {
        SpringApplication.run(ReceiveStarter.class, args);
    }
    @Bean//创建了一个队列
    public Queue test() {
        Queue queue = new Queue("test1");
        return queue;
    }

    @Bean
    public ConnectionFactory connectionFactory() {
        CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
        cachingConnectionFactory.setHost("www.vm.com");
        cachingConnectionFactory.setPort(5672);
        cachingConnectionFactory.setUsername("luke");
        cachingConnectionFactory.setPassword("luke");
        cachingConnectionFactory.setVirtualHost("/test");
        cachingConnectionFactory.setPublisherReturns(true);
        cachingConnectionFactory.setPublisherConfirms(true);
        return cachingConnectionFactory;
    }
}
